#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

static int dayTab[2][13] = {
	{0,31,28,31,30,31,30,31,31,30,31,30,31},
	{0,31,29,31,30,31,30,31,31,30,31,30,31}
};

bool isLeapYear(int year) 
{          
	return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}

int main()
{
	int year, n;
	while (cin >> year >> n) {
		int month = 1, day;
		int row = isLeapYear(year);
		

		while (n > dayTab[row][month]) {
			n -= dayTab[row][month];
			month++;
		}
		day = n;

		printf("%04d-%02d-%02d\n", year, month, day);
	}
	

	return 0;
}